﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
					xmlns:local="clr-namespace:CBR.Components.Controls"
					xmlns:Converters="clr-namespace:CBR.Components.Converters" >

	<Style x:Key="Mode" TargetType="{x:Type RadioButton}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RadioButton}">
					<Border x:Name="border"
                            BorderBrush="Black"
                            Background="Silver"
                            BorderThickness="1"
                            CornerRadius="3"
                            Width="32"
                            Height="32"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center">
						<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter TargetName="border" Property="Background" Value="WhiteSmoke" />
						</Trigger>
						<Trigger Property="IsChecked" Value="True">
							<Setter TargetName="border" Property="Background" Value="DarkGray" />
							<Setter TargetName="border" Property="TextBlock.FontWeight" Value="Bold" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="Corners" TargetType="{x:Type RadioButton}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RadioButton}">
					<Border x:Name="border"
                            BorderBrush="DarkGray"
                            Background="#88C0C0C0"
                            BorderThickness="1"
                            CornerRadius="5"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch" >
						<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter TargetName="border" Property="Background" Value="WhiteSmoke" />
						</Trigger>
						<Trigger Property="IsChecked" Value="True">
							<Setter TargetName="border" Property="Background" Value="White" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
							
	<Style x:Key="{x:Type local:ZoomFlyer}" TargetType="{x:Type local:ZoomFlyer}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:ZoomFlyer}">
					<ControlTemplate.Resources>
						<Storyboard x:Key="HoverOn">
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TemplateGrid" Storyboard.TargetProperty="(UIElement.Opacity)">
								<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
						<Storyboard x:Key="HoverOff">
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TemplateGrid" Storyboard.TargetProperty="(UIElement.Opacity)">
								<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0.2" />
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
					</ControlTemplate.Resources>
					<Grid x:Name="TemplateGrid" Opacity="0.2">
						<Border Padding="6" CornerRadius="5" Background="#88C0C0C0" BorderThickness="1" BorderBrush="DarkGray">
						<Border Padding="5" CornerRadius="8" Background="#88C0C0C0" >
							<StackPanel Orientation="Vertical">
								<Slider Height="140"
                                        Minimum="0.1"
                                        Maximum="5"
                                        Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Scale,Mode=TwoWay}"
                                        HorizontalAlignment="Center"
                                        Ticks="0.1, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2"
                                        AutoToolTipPlacement="BottomRight"
                                        AutoToolTipPrecision="1"
                                        TickPlacement="Both"
                                        TickFrequency="1"
                                        LargeChange="1"
                                        SmallChange="0.1"
                                        Orientation="Vertical" />
								<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Scale,StringFormat='{}{0:F2}x'}"
                                            HorizontalAlignment="Center" FontWeight="Bold" />
							</StackPanel>
						</Border>
						</Border>
						
						<RadioButton Margin="-6" Width="12" Height="12" VerticalAlignment="Top" HorizontalAlignment="Left"
									 Style="{StaticResource Corners}"  GroupName="position"
									 IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Position, Converter={x:Static Converters:EnumToBoolConverter.Instance}, ConverterParameter=TopLeft}" />
						<RadioButton Margin="-6" Width="12" Height="12" VerticalAlignment="Top" HorizontalAlignment="Right"
									 Style="{StaticResource Corners}" GroupName="position"
									 IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Position, Converter={x:Static Converters:EnumToBoolConverter.Instance}, ConverterParameter=TopRight}" />
						<RadioButton Margin="-6" Width="12" Height="12" VerticalAlignment="Bottom" HorizontalAlignment="Left"
									 Style="{StaticResource Corners}" GroupName="position"
									 IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Position, Converter={x:Static Converters:EnumToBoolConverter.Instance}, ConverterParameter=BottomLeft}" />
						<RadioButton Margin="-6" Width="12" Height="12" VerticalAlignment="Bottom" HorizontalAlignment="Right"
									 Style="{StaticResource Corners}" GroupName="position"
									 IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Position, Converter={x:Static Converters:EnumToBoolConverter.Instance}, ConverterParameter=BottomRight}" />
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="true">
							<Trigger.ExitActions>
								<BeginStoryboard Storyboard="{StaticResource HoverOff}" />
							</Trigger.ExitActions>
							<Trigger.EnterActions>
								<BeginStoryboard Storyboard="{StaticResource HoverOn}" />
							</Trigger.EnterActions>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>